import java.io.IOException;

public class Main{

	/**
	 * @param args
	 * @throws IOException
	 * @throws NumberFormatException
	 */
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		java.io.BufferedReader r = new java.io.BufferedReader(
				new java.io.InputStreamReader(System.in));

		int n = Integer.parseInt(r.readLine());
		// int n = 66;
		for (int in = 0; in < n; in++) {

			int number = Integer.parseInt(r.readLine());
			// int number = in + 1;

			if (number != 1) {
				int ax, ay, av = 0;
				int bx, by, bv = 0;
				int rx, ry;
				int pro = 1;
				int i = 0;
				for (i = 0; pro < number; i++) {
					av = pro;
					pro = 1 + 2 * i * (i + 1);
					bv = pro;
				}
				ax = ay = i - 1;
				bx = by = i;

				if (bv == number) {
					rx = bx;
					ry = by;

				} else {

					int mx = bx - 1, my = by, mv = (av + bv) / 2;
					if (number == mv) {
						rx = mx;
						ry = my;
					} else {

						int direction = 1;

						if (number < mv) {
							bv = mv;
							bx = mx;
							by = my;
						} else {
							av = mv;
							ax = mx;
							ay = my;
						}
						int diff = number - av;
						direction = (ax + ay) % 2 == 1 ? direction * -1
								: direction * 1;
						if (direction == 1) {
							if (diff <= ay - 1) {
								ry = ay - diff;
								rx = ax + diff;
							} else {
								ry = diff - ay + 1;
								rx = ax + ay - (diff - ay);
							}
						} else {
							if (diff <= ax - 1) {
								ry = ay + diff;
								rx = ax - diff;
							} else {
								rx = diff - ax + 1;
								ry = ax + ay - (diff - ax);
							}

						}

					}
				}
				System.out.println("TERM " + number + " IS " + ry + "/" + rx);
			} else {
				System.out.println("TERM 1 IS 1/1");
			}
		}
	}
}
